public class Demo14 {
    public static void main(String[] args) throws InterruptedException {
        Object object = new Object();
        Thread t1 = new Thread(() -> {
            synchronized (object){
                while(true){
                    System.out.println("helle thread1");
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        throw new RuntimeException(e);
                    }
                }
            }

        });
        Thread t2 = new Thread(() -> {
            synchronized(object){
                while(true){
                    System.out.println("helle thread2");
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        throw new RuntimeException(e);
                    }
                }
            }
        });
        t1.start();
        t2.start();
        Thread.sleep(1000);
        System.out.println(t2.getState());
    }
}
